package com.eningqu.aipen.utils;

import android.content.Context;
import android.media.Image;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.eningqu.aipen.demo.R;

/**
 * Package:com.eningqu.aipen.utils
 * Author:starr
 * Time:2024/2/4 16:28
 * Description:
 */
public class GlideUtils {
    private static volatile GlideUtils mInstance;

    private GlideUtils(){}
    private static RequestOptions options = new RequestOptions()
            .placeholder(R.drawable.pic_empty) //占位图
            .error(R.drawable.pic_empty)             //错误图
            .skipMemoryCache(true);          //禁用掉Glide的内存缓存功能

    public static GlideUtils getInstance(){
        if(mInstance==null){
            synchronized (GlideUtils.class){
                if(mInstance==null){
                    mInstance = new GlideUtils();
                }
            }
        }
        return mInstance;
    }

    public static void loadImage(Context context, String url, ImageView iv){
        Glide.with(context).load(url).apply(options).into(iv);
    }

    public static void loadCircleImage(Context context, String url, ImageView iv){
        RequestOptions requestOptions=options.centerCrop().circleCrop();
        Glide.with(context).load(url).apply(requestOptions).into(iv);
    }


}
